<?php

namespace Xlib\Form\Element;

use Zend\Form\Element\Text as ZendText;
use Zend\Form\View\Helper\FormText as TextHelper;
use Zend\Form\View\Helper\FormLabel as LabelHelper;
use Xlib\Form\Prepare\AttributesAndLabel;
use Xlib\Form\ElementInterface;

class Text extends ZendText implements ElementInterface {

    use AttributesAndLabel;

    const ELEMENT_TYPE = 'text';

    public function __toString()
    {
        $textHelper  = new TextHelper();
        $labelHelper = new LabelHelper();
        $content  = '<div class="ui-element ui-text">';
        $content .= '<div class="ui-label">';
        $content .= $labelHelper->openTag($this);
        $content .= '<span>' . htmlspecialchars($this->getLabel()) . '</span>';
        $content .= $labelHelper->closeTag();
        $content .= '</div>';
        $content .= '<div class="ui-element">';
        $content .= $textHelper->render($this);
        $content .= '</div>';
        $content .= '</div>';
        return $content;
    }

}
